package com.cloud.sky.controller;

import com.cloud.sky.component.TingYuClient;
import com.cloud.sky.entity.bo.PageBO;
import com.cloud.sky.entity.common.Result;
import com.cloud.sky.entity.dto.BigNodeListDTO;
import com.cloud.sky.entity.vo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 大节点相关
 *
 * @author Tyrone
 * @date 2024/8/1 12:12
 */
@RestController
public class BigNodeController {

    @Autowired
    private TingYuClient tingYuClient;

    /**
     * 查看资源列表
     * @param bigNodeListDTO
     * @return
     */
    @RequestMapping("/machine/all/list")
    public Result<PageBO<BigNodeInfoVO>> listBigNodeInfo(BigNodeListDTO bigNodeListDTO) {
        if (bigNodeListDTO == null) bigNodeListDTO = new BigNodeListDTO();
        PageBO<BigNodeInfoVO> pageBO = tingYuClient.listBigNodeInfo(bigNodeListDTO);
        return Result.success(pageBO);
    }

    @RequestMapping("/machine/all")
    public Result<BigNodeDetailVO> getBigNodeInfoByUUID(String uuid) {
        BigNodeDetailVO bigNodeIngoByUUID = tingYuClient.getBigNodeInfoByUUID(uuid);
        return Result.success(bigNodeIngoByUUID);
    }

    @RequestMapping("/recentlogs")
    public Result<List<BigNodeMonitorInfoVO>> getBigNodeMonitor(String uuid, String startTime, String endTime) {
        List<BigNodeMonitorInfoVO> bigNodeMonitor = tingYuClient.getBigNodeMonitor(uuid, startTime, endTime);
        return Result.success(bigNodeMonitor);
    }


}
